#include <iostream>
#include <cstdio>
#include <ctime>

using namespace std;

int main(){
    char *algs[] = {"Brown", "Korman"};
    char *sizes[] = {"20", "30", "40", "45", "50", "60"};
    char *dens[] = {"0.1", "0.3", "0.5", "0.7", "0.9"};
    char path[100], read[1000], tmp[25], tmp0[100];
    int color, ticks;
    FILE *files[] = {fopen("resBrown.csv", "w"), fopen("resKorman.csv", "w")};
    FILE *fread;
    
    for(int i = 0; i < 2; ++ i){
        for(int j = 0; j < 6; ++ j){
            for(int k = 0; k < 5; ++ k){
                for(int l = 1; l < 4; ++ l){
                    sprintf(path, "%s/%s/%s-%d.txt.out", algs[i], sizes[j], dens[k], l);
                    fread = fopen(path, "r");
                    fscanf(fread, "%s", read);
                    if(read[0] == 'I'){
                        fprintf(files[i], "../Pruebas/%s/%s-%d.txt,%d,%d;\n", sizes[j], dens[k], l, -1, 3600000);
                    }else{
                        for(int m = 0; m < 23; ++ m){
                            tmp[m] = read[m];
                        }
                        tmp[23] = '\0';
                        for(int m = 0; m < 100; ++ m){
                            tmp0[m] = read[23 + m];
                            if(tmp[m] == '\0')
                                break;
                        }
                        sscanf(tmp0, ",%d,%d", &color, &ticks);
                        fprintf(files[i], "%s,%d,%d;\n", tmp, color, (int)((ticks * 10000) / (CLOCKS_PER_SEC / 1000)));
                    }
                    fclose(fread);
                }
            }
        }
    }
}